﻿using System;

namespace PaceR.Core.Extensions
{
	public static class NullCheckExtensions
	{
		public static TResult IfNotNull<TSource, TResult>(this TSource source, Func<TSource, TResult> function)
		{
			if (source != null)
				return function(source);

			return default(TResult);
		}

		public static bool IfNotNull<TSource>(this TSource source, Action<TSource> action)
		{
			if (source != null)
			{
				action(source);
				return true;
			}

			return false;
		}
	}
}
